/*
 * @Author: your name
 * @Date: 2021-07-22 10:55:12
 * @LastEditTime: 2021-09-26 16:35:56
 * @LastEditors: zhl
 * @Description: In User Settings Edit
 * @FilePath: \Test\include\Parse_Packet.h
 */
#ifndef __PARSE_PACKET_H__
#define __PARSE_PACKET_H__

#include <utility>

#include "dlt698_frame.h"

using namespace std;

class Parse_Packet{
    public:

        Parse_Packet();
        ~Parse_Packet();

        static Parse_Packet &getInstance();

        DLT698_FRAME *get_frame(const uint8_t *frame, int len);

        uint8_t  get_frame_sc(const uint8_t *frame, int len);
        uint16_t get_frame_l(const uint8_t *frame, int len);
        uint8_t  get_frame_c(const uint8_t *frame, int len);
        uint8_t  get_frame_sa_sc(const uint8_t *frame, int len);
        pair<uint8_t, uint8_t*>  get_frame_sa(const uint8_t *frame, int len);
        uint8_t  get_frame_ca(const uint8_t *frame, int len);
        uint16_t get_frame_hcs(const uint8_t *frame, int len);
        pair<uint16_t, uint8_t*> get_apdu(const uint8_t *frame, int len);
        uint16_t get_frame_fcs(const uint8_t *frame, int len);
        uint8_t  get_frame_em(const uint8_t *frame, int len);
        uint16_t get_apdu_len(const uint8_t *frame, int len);
        
        //获取控制域格式化内容
        TRANSMIT_INITIATE_DIRECTION get_frame_c_direction(const uint8_t c);
        uint8_t get_frame_c_subframe_flag(const uint8_t c);
        uint8_t get_frame_c_mix_code(const uint8_t c);
        uint8_t get_frame_c_func_code(const uint8_t c);
        //获取地址域格式化内容
        DLT698_FRAME_SA_TYPE get_frame_sa_sc_addr_type(const uint8_t sa_sc);
        uint8_t get_frame_sa_sc_logic_addr(const uint8_t sa_sc);
        uint8_t get_frame_sa_sc_addr_len(const uint8_t sa_sc);

        uint8_t get_apdu_type(const uint8_t *frame, int len);


    private:
        static Parse_Packet  c_instance;
        DLT698_FRAME  c_dlt698_frame;

    private:
        uint8_t  *get_real_data(const uint8_t *frame, int len);

};





#endif